package com.itheima.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.itheima.mapper.OperateLogMapper;
import com.itheima.pojo.OperateLog;
import com.itheima.pojo.OperateLogPageRequest;
import com.itheima.pojo.PageResponseResult;
import com.itheima.service.OperateLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OperateLogServiceImpl implements OperateLogService {
    @Autowired
    private OperateLogMapper operateLogMapper;


    /* 日志列表查询*/
    @Override
    public PageResponseResult queryOperateLog(OperateLogPageRequest operateLogPageRequest) {
//        1.传入分页参数
        PageHelper.startPage(operateLogPageRequest.getPage(),operateLogPageRequest.getPageSize());

//        2.调用mapper层的方法
        List<OperateLog> operateLogList = operateLogMapper.queryOperateLog();

//        3.进行解析参数
        Page<OperateLog> operateLogs = (Page<OperateLog>) operateLogList;

//        4.进行封装结果
        return new PageResponseResult(operateLogs.getTotal(),operateLogs.getResult());

    }
}
